
class Student:
    def __init__(self,name,age):
        self.name=name
        self.age=age

    # __str__字符串方法
    def __str__(self):
        return f"Student类对象，name：{self.name},age:{self.age}"
    # __lt__小于符号比较方法
    def __lt__(self, other):
        return self.age<other.age
    #__le__小于等于符号比较
    def __le__(self, other):
        return self.age<=other.age
    #__eq__相等符号比较   不用此魔术方法，默认比较的是内存地址
    def __eq__(self, other):
        return self.age==other.age




stu=Student("迪丽热巴",21)
stu2=Student("杨超越",21)
print(stu)
print(str(stu))
print(stu<=stu2)
print(stu==stu2)


